package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleService;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.comment.dtos.CommentConfigDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.StatisticsDto;
import com.heima.model.wemedia.dtos.WmStatisticDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "远程调用保存文章相关接口", tags = "远程调用保存文章相关接口")
public class ArticleClient implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;

    @Override
    @PostMapping("/api/v1/article/save")
    @ApiOperation("自媒体端审核通过 保存文章")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto) {return apArticleService.saveArticle(dto);}

    /**
     * 查询文章是否可以评论
     *
     * @param articleId
     * @return
     */
    @Override
    @GetMapping("/api/v1/article/findArticleConfigByArticleId/{articleId}")
    @ApiOperation("app端查询文章是否能够评论")
    public ResponseResult findArticleConfigByArticleId(@PathVariable("articleId") Long articleId) {return apArticleService.findArticleConfigByArticleId(articleId);}

    /**
     * 自媒体端查询文章表的信息
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/findNewsComments")
    @ApiOperation("自媒体端查询文章表的评论相关信息")
    public PageResponseResult findNewsComments(ArticleCommentDto dto) {return apArticleService.findNewsComments(dto);}

    /**
     * 修改app文章的config配置
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/updateCommentStatus")
    @ApiOperation("自媒体端修改app文章的评论权限")
    public ResponseResult updateCommentStatus(CommentConfigDto dto) {return apArticleService.updateCommentStatus(dto);}

    /**
     * 分页查询图文统计
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/newPage")
    @ApiOperation("分页查询图文统计")
    public PageResponseResult newPage(@RequestBody StatisticsDto dto) {return apArticleService.newPage(dto);}

    /**
     * 获取图文数据
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/article/queryLikesAndConllections")
    @ApiOperation("获取图文数据(发布点赞收藏)")
    public ResponseResult queryLikesAndCollections(@RequestBody WmStatisticDto dto) {return apArticleService.queryLikesAndCollections(dto);}
}
